package cn.yzfy.api;

import cn.yzfy.common.base.dto.BaseLongIdDTO;
import cn.yzfy.common.base.dto.BaseManyLongIdDTO;
import cn.yzfy.common.model.dto.AddRouteDTO;
import cn.yzfy.common.model.dto.EditRouteDTO;
import cn.yzfy.common.model.dto.RouteQueryPageDTO;
import cn.yzfy.common.model.vo.RouteVO;
import cn.yzfy.service.IRouteService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 一朝风月
 * @date 2025/9/11 16:23
 * @Code 面向注解面向卿，终无解释再无你
 * @description
 */
@Tag(name = "骑行路线接口")
@RestController
@RequestMapping("/route")
@RequiredArgsConstructor
public class RouteController {
    private final IRouteService routeService;
    @Operation(summary = "分页查询", description = "分页查询骑行路线接口}")
    @GetMapping(value = "/pageQueryList", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponse(responseCode = "200", description = "OK")
    public Page<RouteVO> pageQueryList(RouteQueryPageDTO inputDTO) {
        return routeService.pageQueryList(inputDTO);
    }

    @Operation(summary = "ID查询", description = "ID查询骑行路线接口}")
    @GetMapping(value = "/getRoute", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponse(responseCode = "200", description = "OK")
    public RouteVO getOne(@Validated BaseLongIdDTO inputDTO) {
        return routeService.getOne(inputDTO);
    }

    @Operation(summary = "添加骑行路线", description = "添加骑行路线接口")
    @ApiResponse(responseCode = "200", description = "OK")
    @PostMapping(value = "/addRoute", produces = MediaType.APPLICATION_JSON_VALUE)
    public Boolean addRoute(@RequestBody @Validated AddRouteDTO inputDTO) {
        return routeService.addRoute(inputDTO);
    }

    @Operation(summary = "删除骑行路线", description = "根据id删除接口")
    @ApiResponse(responseCode = "200", description = "OK")
    @DeleteMapping(value = "/delRoute", produces = MediaType.APPLICATION_JSON_VALUE)
    public Boolean delRoute(@RequestBody @Validated BaseManyLongIdDTO inputDTO) {
        return routeService.delRoute(inputDTO);
    }

    @Operation(summary = "编辑骑行路线", description = "编辑骑行路线接口")
    @ApiResponse(responseCode = "200", description = "OK")
    @PatchMapping(value = "/editRoute", produces = MediaType.APPLICATION_JSON_VALUE)
    public Boolean addRoute(@RequestBody @Validated EditRouteDTO inputDTO) {
        return routeService.editRoute(inputDTO);
    }
}
